/**  
 * File Name:SpecialStringDerializer.java  
 * Package Name:com.suneee.core.util  
 * Description: (That's the purpose of the file)
 * Date:2015年1月19日上午10:52:54  
 * Copyright (c) 2015, forint.lee@qq.com All Rights Reserved.  
 *  
*/

package com.base.core.type;

import java.io.IOException;
import java.text.ParseException;
import java.util.Date;

import com.base.core.error.ErrorUtils;
import com.base.core.error.GenericError;
import com.base.core.util.DateUtils;
import com.base.core.util.StringUtils;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;


/**  
 * ClassName:SpecialStringDerializer <br/>  
 * Description:That's the purpose of the class
 * Date:     2015年1月19日 上午10:52:54 <br/>  
 * @author   Forint  
 * @version  V1.0  
 * @see        
 */
public class SpecialDateDerializer extends JsonDeserializer<Date> {
	@Override
	public Date deserialize(JsonParser jp, DeserializationContext ctxt)
			throws IOException, JsonProcessingException {
	    if (!StringUtils.isBlank(jp.getText())) {
	    	try {
                return DateUtils.pownerParseDate(jp.getText().trim());
            } catch (ParseException e) {
                throw ErrorUtils.wrap(GenericError.DATAFORMAT, e);
            }
	    }
	    return null;
	}
}
  
